<?php 
namespace app\index\model;
use think\Model;
use think\Session;
use think\Db;
header("Content-type: text/html; charset=utf-8");
class Listuser_model extends Model
{
	public function listuser()
	{
		
		$where['username'] = session('username');
		$ip 	           = $_SERVER['REMOTE_ADDR'];
		$json              = file_get_contents("http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=".$ip);
		$json              = json_decode($json, true);
		$data['ip']        = $ip;
		$data['username']  = $where['username'];
		$data['datatime']  = date('Y-m-d H:i:s',time());;
		$data['country']   = $json["country"];
		$data['province']  = $json["province"];
		$data['city']      = $json["city"];
		$data['district']  = $json["district"];
		$data['isp']       = $json["isp"];
		$model = Db::table("address")->where('username',$where['username'])->setField($data);
		$idmodel = Db::table('address')->where('username',$where['username'])->select();
		return $idmodel;
	}
}